<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Event Handling</title>
    <link rel="stylesheet" href="../assets/styles.css" />
    <!-- 方式一：使用线上CDN -->
    <!-- <script src="https://unpkg.com/vue@3"></script> -->
    <!-- 方式二：下载线上CDN到本地 -->
    <script src="../vue@3.2.37.js"></script>
  </head>
  <body>
    <div id="app">
      <div class="nav-bar"></div>
      <div class="cart">Cart({{cart}})</div>

      <div class="product-display">
        <div class="product-container">
          <div class="product-image">
            <img :src="image" />
          </div>
          <div class="product-info">
            <h1>{{product}}</h1>
            <p v-if="inventory">有库存</p>
            <p v-else>没库存</p>
            <ul>
              <li v-for="detail in details">{{detail}}</li>
            </ul>
            <div
              v-for="variant in variants"
              :key="variant.id"
              @mouseover="updateImage(variant.image)"
            >
              {{variant.color}}
            </div>
            <button class="button" @click="addToCart">添加到购物车</button>
          </div>
        </div>
      </div>
    </div>

    <script src="./main.js"></script>
    <script>
      // 可在控制台给vm.product赋值看到页面数据立马变化
      const vm = app.mount("#app")
    </script>
  </body>
</html>
